package com.hwl.demo11;

import com.hwl.demo11.entity.Department;
import com.hwl.demo11.entity.User;
import com.hwl.demo11.factory.SqlServerFactory;
import com.hwl.demo11.service.IDepartment;
import com.hwl.demo11.service.IFactory;
import com.hwl.demo11.service.IUser;

/**
 * 抽象工厂模式
 *
 * @author sentry
 * @since 2023-03-19
 */
public class Main {

    public static void main(String[] args) {
        IFactory factory = new SqlServerFactory();
        IUser iu = factory.createUser();
        IDepartment dept = factory.createDepartment();

        User user = new User();
        iu.insert(user);
        iu.getUser(1);

        Department department = new Department();
        dept.insert(department);
        dept.getDepartment(2);

        System.out.println("=============分割线===============");

        IUser iUser = DataAccess.createUser();
        IDepartment iDepartment = DataAccess.createDepartment();

        iUser.insert(user);
        iUser.getUser(2);

        iDepartment.insert(department);
        iDepartment.getDepartment(3);
    }
}
